import request from "../utils/request"
/**
 *
 * @param {*} params
 * @returns 组织架构
 */
function getObtainOrganizationalStructure(param, component) {

    return request.post("/getSearchCondition/organize", param).then(res => {

        let data = res.data[0];

        console.log("res.data", data);

        component.obtainOrganizationalStructure = data;

        component.invitationDepartment = data;

        component.designatedNegotiator = res.data[1];


        console.log("invitationDepartment", component.invitationDepartment);

        console.log("designatedNegotiator", component.designatedNegotiator);

        return res.data;

    });
}

function refreshOriginalStructures(param, component) {
    return request.post("/getSearchCondition/refreshOriginalStructures", param).then(res => {

        let data = res.data;

        console.log("res.data", data);

        component.invitationDepartment = data;

        console.log("invitationDepartment", component.invitationDepartment);

        return res.data;

    });
}

/**
 *
 * @param {{}} params
 * @returns 组织架构
 */
function getObtainStaffStructure(param, component) {

    return request.post("/getSearchCondition/getFranchiseBusinessUnit", param).then(res => {

        let data = res.data;

        console.log("res.data", data);

        component.invitationDepartment = data;

        console.log("invitationDepartment", component.invitationDepartment);

        return res.data;

    });
}


/**
 * 分配客户
 */
function dispatchClient(param, component) {

    return request.post("/getSearchCondition/dispatchClient", param).then(res => {

        // component.citys = res.data;

        // console.log("component.citys", component.citys);
        return res;

    });

}


/**
 * 获取分配客户
 */
function getDispatchClient(param, component) {

    return request.post("/getSearchCondition/getDispatchClient", param).then(res => {

        component.list = res.data;

        console.log("component.citys", component.citys);
        return res;

    });

}

function returningToExploreHorses(param, component) {

    return request.post("/getSearchCondition/returningToExploreHorses", param).then(res => {


        console.log("res", res);
        return res;

    });

}


function getCitys(component) {

    return request.post("/getSearchCondition/getCitys", {}).then(res => {

        component.citys = res.data;

        console.log("component.citys", component.citys);
        return res;

    });


}

function getAssignHistory(param, component) {

    return request.post("/dispatchRecord/listVO", param).then(res => {



        let list = res.data.data;

        list.forEach(element => {
            element.createTime *=1000;
        });

        component.list = list;

        component.pageSize = res.data.pageSize;

        component.total = res.data.total;

        console.log("component.list", component.list);
        return res;

    });


}

function getAssignHistorySearch(param, component) {

    return request.post("/dispatchRecord/listBySearchVO", param).then(res => {

        let list = res.data.data;

        list.forEach(element => {
            element.createTime *=1000;
        });

        component.list = list;

        component.pageSize = res.data.pageSize;



        component.total = res.data.total;

        console.log("component.citys", component.citys);
        return res;

    });


}

function getAssignCommpanyHistory(param, component) {

    return request.post("/dispatchCompanyRecordController/listVO", param).then(res => {

        component.companys = res.data.data;

        component.pageSize = res.data.pageSize;
        component.total = res.data.total;

        component.lastId = component.companys[0].id;

        console.log("component.pageSize", component.pageSize);
        return res;

    });


}


export {
    getDispatchClient,
    getObtainOrganizationalStructure,
    getCitys,
    getObtainStaffStructure,
    getAssignCommpanyHistory,
    getAssignHistorySearch,
    refreshOriginalStructures,
    getAssignHistory,
    returningToExploreHorses,
    dispatchClient
}

/**
 * : 405 Not Allowed: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><EOL><EOL><html><EOL><EOL><head><title>405 Not Allowed</title></head><EOL><EOL><body><EOL><EOL><center><h1>405 Not Allowed</h1></center><EOL><EOL> Sorry for the inconvenience.<br/><EOL><EOL>Please report this message and include the following information to us.<br/><EOL><EOL>Thank you very much!</p><EOL><EOL><table><EOL><EOL><tr><EOL><EOL><td>URL:</td><EOL><EOL><td>http://account.tanmarket.cn:3210/api/v3/highsea/customerRepo</td><EOL><EOL></tr><EOL><EOL><tr><EOL><EOL><td>Server:</td><EOL><EOL><td>web001</td><EOL><EOL></tr><EOL><EOL><tr><EOL><EOL><td>Date:</td><EOL><EOL><td>2023/12/05 16:06:39</td><EOL><EOL></tr><EOL><EOL></table><EOL><EOL><hr/>Powered by Tengine<hr><center>tengine</center><EOL><EOL></body><EOL><EOL></html><EOL><EOL>"

 */